package com.firefly.app.biz.wechat;

import java.util.HashMap;
import java.util.Map;

import com.firefly.mobile.app.config.Config;
import com.firefly.mobile.app.util.AndroidSystemUtil;
import com.firefly.mobile.app.util.HttpUtil;
import com.firefly.mobile.app.util.Md5;

public class WechatServiceImpl implements WechatService{

	private static String url = Config.getString("wechat.proxy.url");
	private static String key = Config.getString("wechat.proxy.key");
	
	@Override
	public String preWechatOrder(String tradeNo,String transId, String transAmt) {
		String Wechaturl = url+"appPayOrder.htm";
		Map<String, String> paramsMap = new HashMap<String, String>();
		//获取日期
		String subject = "赢火虫";
		String total_fee = transAmt;
		String ip = AndroidSystemUtil.getIpAddress();
		paramsMap.put("desc", subject);
		paramsMap.put("orderAmt", total_fee);
		paramsMap.put("tradeNo", tradeNo);
		paramsMap.put("ip", ip);
		String sign = Md5.md5(tradeNo+transAmt +subject +ip+ key);
		paramsMap.put("sign", sign);
		String result = "";
		try {
			result = HttpUtil.getUrlAsString(Wechaturl, paramsMap);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("http result :" + result);
		return result;
	}


}
